package com.zxy.health.service;

import com.zxy.health.dao.InputSchoolDao;
import com.zxy.health.dao.ReportDao;
import com.zxy.health.mapper.InputSchoolMapper;
import com.zxy.health.mapper.StudentMapper;
import com.zxy.health.utils.DateUtils;
import com.zxy.health.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class InputSchoolService {
    @Autowired
    StudentMapper studentMapper;
    @Autowired
    InputSchoolMapper inputSchoolMapper;
    public String addStudentInputschool(String userId){

        if (studentMapper.getStudentBySchoolId(userId).size()==0){
            return "账户未注册";
        }else {
            InputSchoolDao inputSchoolDao = new InputSchoolDao();
            inputSchoolDao.setId(StringUtils.getSimpleUUID());
            inputSchoolDao.setUserid(userId);
            inputSchoolDao.setTime(new Date().getTime());
            inputSchoolDao.setState(1);
            inputSchoolMapper.addInputSchoolRecord(inputSchoolDao);
            return "success";
        }
    }

    public String addStudentOutputschool(String userId){

        if (studentMapper.getStudentBySchoolId(userId).size()==0){
            return "账户未注册";
        }else {
            InputSchoolDao inputSchoolDao = new InputSchoolDao();
            inputSchoolDao.setId(StringUtils.getSimpleUUID());
            inputSchoolDao.setTime(new Date().getTime());
            inputSchoolDao.setUserid(userId);
            inputSchoolDao.setState(0);
            inputSchoolMapper.addInputSchoolRecord(inputSchoolDao);
            return "success";
        }
    }

    public List<InputSchoolDao> getInputSchoolRecordById(String userid){
        return inputSchoolMapper.getInputSchoolRecordBySchoolId(userid);
    }
}
